package com.cheyunkeji.er.fragment.evaluate;

import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.cheyun.netsalev3.R;
import com.cheyunkeji.er.activity.evaluate.EvaluateHomePageActivity;
import com.cheyunkeji.er.activity.evaluate.EvaluateWorkflowActivity;
import com.cheyunkeji.er.base.BaseFragment;
import com.cheyunkeji.er.view.TopBar;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Michael on 2017/3/16 15:15.
 */

public class EvaluateFragment extends BaseFragment {

    private static final int REQUEST_CODE_ADD_NEW_ARCHIVE = 0X120 ;
    private static final String TAG = EvaluateFragment.class.getSimpleName() ;

    @BindView(R.id.v_topbar)
    TopBar vTopbar;
//    @BindView(R.id.eiv_evaluate_basic_info)
//    EvaluateItemView eivEvaluateBasicInfo;
//    @BindView(R.id.eiv_car_basic_info)
//    EvaluateItemView eivCarBasicInfo;
//    @BindView(R.id.eiv_car_config_info)
//    EvaluateItemView eivCarConfigInfo;
//    @BindView(R.id.eiv_take_photo)
//    EvaluateItemView eivTakePhoto;
//    @BindView(R.id.eiv_csgj_check)
//    EvaluateItemView eivCsgjCheck;
//    @BindView(R.id.eiv_wgyct_check)
//    EvaluateItemView eivWgyctCheck;
//    @BindView(R.id.eiv_qimian_check)
//    EvaluateItemView eivQimianCheck;
//    @BindView(R.id.eiv_luntai_check)
//    EvaluateItemView eivLuntaiCheck;
//    @BindView(R.id.eiv_fdjc_check)
//    EvaluateItemView eivFdjcCheck;
//    @BindView(R.id.eiv_jsc_check)
//    EvaluateItemView eivJscCheck;
//    @BindView(R.id.eiv_qidong_check)
//    EvaluateItemView eivQidongCheck;
//    @BindView(R.id.eiv_lushi_check)
//    EvaluateItemView eivLushiCheck;
//    @BindView(R.id.eiv_dipan_check)
//    EvaluateItemView eivDipanCheck;
//    @BindView(R.id.eiv_gnxlbj_check)
//    EvaluateItemView eivGnxlbjCheck;
//    @BindView(R.id.eiv_jcjgpz)
//    EvaluateItemView eivJcjgpz;
//    @BindView(R.id.tv_evaluate_addnew)
//    Button tvEvaluateAddnew;

    @Override
    protected void doInflaterView(LayoutInflater inflater, ViewGroup container) {
        contentView = inflater.inflate(R.layout.er_frag_evaluate, null);
        ButterKnife.bind(this, contentView);
    }

    @Override
    protected void init() {

    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);

        Log.e(TAG, "onHiddenChanged: Fragment 是否隐藏 ： " + hidden );

        if(!hidden){
            showDialog();
            Intent intent = new Intent(getActivity(),EvaluateWorkflowActivity.class);
            startActivityForResult(intent,REQUEST_CODE_ADD_NEW_ARCHIVE);
            dismissDialog();

            Log.e(TAG, "setUserVisibleHint: 开始跳转 "  );
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        Log.e(TAG, "onActivityResult: 回退到评估 Fragment "  );

        if(requestCode == REQUEST_CODE_ADD_NEW_ARCHIVE ){

            ((EvaluateHomePageActivity)getActivity()).setCurrentTab(0);
        }

    }

    @Override
    protected void initView() {
        vTopbar.setTitle("评估");
        loadDialog.setCanceledOnTouchOutside(true);
//        vTopbar.setRight("", R.mipmap.icon_add, this);
//        eivEvaluateBasicInfo.setOnClickListener(this);
//        eivCarBasicInfo.setOnClickListener(this);
//        eivCarConfigInfo.setOnClickListener(this);
//        eivTakePhoto.setOnClickListener(this);
//        eivCsgjCheck.setOnClickListener(this);
//        eivWgyctCheck.setOnClickListener(this);
//        eivQimianCheck.setOnClickListener(this);
//        eivLuntaiCheck.setOnClickListener(this);
//        eivFdjcCheck.setOnClickListener(this);
//        eivJscCheck.setOnClickListener(this);
//        eivQidongCheck.setOnClickListener(this);
//        eivLushiCheck.setOnClickListener(this);
//        eivDipanCheck.setOnClickListener(this);
//        eivGnxlbjCheck.setOnClickListener(this);
//        eivJcjgpz.setOnClickListener(this);
//        tvEvaluateAddnew.setOnClickListener(this);

        showDialog();
        Intent intent = new Intent(getActivity(),EvaluateWorkflowActivity.class);
        startActivityForResult(intent,REQUEST_CODE_ADD_NEW_ARCHIVE);
        dismissDialog();

    }

    @Override
    protected void initData() {

    }

    /*
    @Override
    public void onClick(View v) {
        super.onClick(v);

        switch (v.getId()) {
            case R.id.eiv_evaluate_basic_info:
                jumpToEvaluateProcessPageAt(EvaluateBaseInfoFragment.PAGE_INDEX);
                break;
            case R.id.eiv_car_basic_info:
                jumpToEvaluateProcessPageAt(CarBaseInfoFragment.PAGE_INDEX);
                break;
            case R.id.eiv_car_config_info:
                jumpToEvaluateProcessPageAt(CarConfigInfoFragment.PAGE_INDEX);
                break;
            case R.id.eiv_take_photo:
                jumpToEvaluateProcessPageAt(TakeCarPhotoFragment.PAGE_INDEX);
                break;
            case R.id.eiv_csgj_check:
                jumpToEvaluateProcessPageAt(CarFrameworkCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_wgyct_check:
                jumpToEvaluateProcessPageAt(AppearanceCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_qimian_check:
                jumpToEvaluateProcessPageAt(CarLacquerCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_luntai_check:
                jumpToEvaluateProcessPageAt(TyreCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_fdjc_check:
                jumpToEvaluateProcessPageAt(EngineCabinCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_jsc_check:
                jumpToEvaluateProcessPageAt(DriveCabinCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_qidong_check:
                jumpToEvaluateProcessPageAt(StartCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_lushi_check:
                jumpToEvaluateProcessPageAt(RoadTestCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_dipan_check:
                jumpToEvaluateProcessPageAt(DiPanCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_gnxlbj_check:
                jumpToEvaluateProcessPageAt(FunctionalityPartsCheckFragment.PAGE_INDEX);
                break;
            case R.id.eiv_jcjgpz:
                jumpToEvaluateProcessPageAt(CheckResultPz.PAGE_INDEX);
                break;

            case R.id.tv_evaluate_addnew:
            case R.id.vRight:
                MyApplication.clearEvaluateResult();
                Intent intent = new Intent(getActivity(),EvaluateWorkflowActivity.class);
                intent.putExtra(Constants.EVALUATE_ARCHIVE_TYPE,Constants.ARCHIVE_TYPE_CREATE_NEW_EVALUATE);
                startActivity(intent);
                break;

            default:
                break;

        }
    }



    private void jumpToEvaluateProcessPageAt(int pageIndex) {

        Intent intent = new Intent(getActivity(),EvaluateWorkflowActivity.class);
        intent.putExtra("PAGE_INDEX",pageIndex);
        startActivity(intent);
    }

    */

}
